import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login') // 获取要跳转页面的位置
  },
  {
    path: '/',
    // name: 'layout', //当父标签有默认子路由的时候 父标签的name属性没有意义
    component: () => import('@/views/layout'), // 获取要跳转页面的位置
    children: [
      {
        path: '', // 默认子路由
        name: 'home',
        component: () => import('@/views/home') // 获取要跳转页面的位置
      },
      {
        path: 'my',
        name: 'my',
        component: () => import('@/views/my') // 获取要跳转页面的位置
      },
      {
        path: 'qa',
        name: 'qa',
        component: () => import('@/views/qa') // 获取要跳转页面的位置
      },
      {
        path: 'video',
        name: 'video',
        component: () => import('@/views/video') // 获取要跳转页面的位置
      }
    ]
  },
  {
    path: '/search',
    name: 'search',
    component: () => import('@/views/search') // 搜索页面
  },
  {
    path: '/article/:articleId',
    name: 'article',
    component: () => import('@/views/article'),
    props: true
  },
  {
    path: '/info',
    name: 'info',
    component: () => import('@/views/info')
  }
]

const router = new VueRouter({
  routes
})

export default router
